import * as apiService from '@/services/api.js';

import store from '@/store';

/**
 * 获取推广素材
 *
 */
const materialApi = async(params) => {
  const [result,data] = await apiService.post('/gl/proxy/list/material', params);

  return [result,data];
};

/**
 * 获取推广域名
 */
const proxyInfoApi = async() => {
  const [result,data] = await apiService.post(`${consts.PROXY_PREV}/proxy/domain`, {
    proxyId: store.getters.userId,
    page: 1,
    size: 20
  });

  return [result,data];
};

/**
 * 添加/编辑代理域名
 */
const addDomainApi = async({domainId, name}) => {
  if (domainId) {
    const [result,data] = await apiService.post('/gl/proxy/update/domain', {
      domainId,
      name,
    });

    return [result,data];
  } else {

    const [result,data] = await apiService.post('/gl/proxy/add/domain', {
      name
    });

    return [result,data];
  }
};


export {
  materialApi,
  proxyInfoApi,
  addDomainApi,
};
